<?php

class MatchType extends Eloquent {
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'match_type';

	/**
	 * Fetches all the matches that belongs to this type
	 *
	 * @return Match array
	 */
	public function matches()
    {
        return $this->hasMany('Match', 'id', 'matchTypeId');
    }
    
    /**
     * Fetches all the fields in which this match type can be played
     *
     * @return Field array
     */
    public function fields()
    {
    	return $this->belongsToMany('Field', 'field_matchtypes', 'matchTypeId', 'fieldId');
    }
}
